home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / addnums.zip / ADDNUMS.BAS < prev    next >
BASIC Source File  |  1990-09-13  |  3KB  |  117 lines

  1. ' ADDNUMS - Adds Numbers to BASIC program which has none
  2.  
  3. ' Version 1.00  09/05/86
  4. ' Version 1.01  09/12/90  P.D.Q. changes.
  5.  
  6. ' (C) Copyright 1986, 1990 by William D. Hileman
  7. '                             Route 3, Box 467
  8. '                             Trenton, FL  32693
  9. '                             (904) 463-1680
  10. '
  11. '                         and Knowledge Applied Technologies, Inc.
  12. '                             502 NW 75th Street, Suite #214
  13. '                             Gainesville, FL 32607
  14.  
  15. declare function pdqexist%(fl.spec$)
  16.  
  17. defint a-z
  18.  
  19. version$="1.01"
  20. versdate$="09/12/90"
  21.  
  22. cls
  23. print "┌─────────────────────────────────────────────────┐"
  24. print "│ ADDNUMS - Number Inserter Version ";version$;" ";versdate$;" │"
  25. print "│ (C) Copyright 1986, 1990 by William D. Hileman  │"
  26. print "└─────────────────────────────────────────────────┘"
  27. print
  28.  
  29. ' Get source filename
  30.  
  31. src.name$=ucase$(ltrim$(rtrim$(command$)))
  32. if src.name$="" then
  33.   line input "Enter Source Filename: ";src.name$
  34.   src.name$=ucase$(ltrim$(rtrim$(src.name$)))
  35.   print
  36. elseif src.name$="?" then
  37.   gosub help
  38.   goto done
  39. end if
  40.  
  41. if src.name$="" then
  42.   goto done
  43. end if
  44.  
  45. x=instr(src.name$,".")
  46. if x=0 then
  47.   dest.name$=src.name$+".NUM"
  48.   src.name$=src.name$+".BAS"
  49. elseif mid$(src.name$,x+1)="NUM" then
  50.   print "Source file cannot have extension 'NUM'!"
  51.   beep
  52.   goto done
  53. else
  54.   dest.name$=left$(src.name$,x)+"NUM"
  55. end if
  56.  
  57. if not pdqexist(src.name$) then
  58.   print "Source file '";src.name$;"' not found!"
  59.   beep
  60.   goto done
  61. end if
  62.  
  63. open src.name$ for input as #1
  64.  
  65. open dest.name$ for output as #2
  66.  
  67. print "Creating File: '";dest.name$;"'";
  68.  
  69. lin%=0
  70. sup%=0
  71.  
  72. while not eof(1)
  73.   line input #1,i$
  74.   if sup% then
  75.     o$=space$(len(ltrim$(str$(lin%))))+" "+i$
  76.   else
  77.     lin%=lin%+1
  78.     o$=ltrim$(str$(lin%))+" "+i$
  79.   end if
  80.   print #2,o$
  81.   if right$(i$,1)="_" then
  82.     sup%=-1
  83.   else
  84.     sup%=0
  85.   end if
  86. wend
  87.  
  88. print
  89.  
  90. done:
  91.  
  92. close
  93. end
  94.  
  95. ' Display help message (command line syntax)
  96.  
  97. help:
  98.  
  99. print "┌─────────────────────────────────────────────────────────────────────┐"
  100. print "│ ADDNUMS  is a utility which reads an ASCII file and creates a  file │"
  101. print "│ with  the  same filename and the extension '.NUM'.  This  new  file │"
  102. print "│ has  line numbers starting with '1' on all logical  lines.  If  the │"
  103. print "│ last character on the line is an underscore (_), the line following │"
  104. print "│ it will not contain a line number, but will be indented the  proper │"
  105. print "│ number of spaces.  This utility is designed to debug BASIC programs │"
  106. print "│ written without line numbers, whose error codes during testing  are │"
  107. print "│ ambiguous.   The default source file extension is '.BAS'.           │"
  108. print "├─────────────────────────────────────────────────────────────────────┤"
  109. print "│ ADDNUMS accepts the following syntax:                               │"
  110. print "├─────────────────────────────────────────────────────────────────────┤"
  111. print "│ ADDNUMS ?                    - displays this message                │"
  112. print "│ ADDNUMS d:\path\filename.ext - creates d:\path\filename.NUM         │"
  113. print "│ ADDNUMS                      - prompts for source filespec          │"
  114. print "└─────────────────────────────────────────────────────────────────────┘"
  115.  
  116. return
  117.